//
//  MessageLineDetailCell.m
//  carcareIOS
//
//  Created by 王然 on 16/9/2.
//  Copyright © 2016年 chezheng. All rights reserved.
//

#import "MessageLineDetailCell.h"
#import "MessageListV.h"

@interface MessageLineDetailCell()

@property (nonatomic , strong) MessageListV * messageV;

@property (nonatomic , strong) UIView * topLineV;

@property (nonatomic , strong) UIView * bottomLineV;

@end

@implementation MessageLineDetailCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [Theme backGroundColor];
        [self createUI];
    }
    return self;
}
- (void)createUI
{
    CGFloat cornerW = 6;
    self.topLineV = [[[UIView viewWithFrame:CGRectMake(CarListV_Line_Left, 0, 1, Label_Y + Label_Height / 2 - cornerW + SECTION_HEIGHT)] setupOnView:self] resetBackgroundColor:COLOR_HEXSTRING(@"#c8c8c8")];
    self.cornerV = [[[[UIView viewWithFrame:CGRectMake(self.topLineV.right - self.topLineV.width / 2 - cornerW / 2, self.topLineV.bottom + cornerW / 2, cornerW, cornerW)] setupOnView:self] resetBackgroundColor:[Theme orangeColor]] resetCornerRadius:cornerW / 2];
    CGFloat bottomLineVY = self.cornerV.bottom + cornerW / 2;
    self.bottomLineV = [[[UIView viewWithFrame:CGRectMake(self.topLineV.left, bottomLineVY, self.topLineV.width, [MessageListV getListCellHeightWithModel:nil] + SECTION_HEIGHT * 2 - bottomLineVY)] setupOnView:self] resetBackgroundColor:self.topLineV.backgroundColor];
    
    self.messageV = [[[MessageListV alloc]initWithWidth:CarListV_Width] setupOnView:self];
    [self.messageV setOrigin:CGPointMake(CarListV_Left, SECTION_HEIGHT)];
}
- (void)setTopLineVHidden:(BOOL)topLineVHidden
{
    _topLineVHidden = topLineVHidden;
    [self.topLineV setHidden:topLineVHidden];
}
- (void)setBottomLineVHidden:(BOOL)bottomLineVHidden
{
    _bottomLineVHidden = bottomLineVHidden;
    [self.bottomLineV setHidden:bottomLineVHidden];
}
- (void)reloadDataWithModel:(MessageModel *)model
{
    if(self.clickLabelURL) self.messageV.clickLabelURL = self.clickLabelURL;
    [self.bottomLineV setHeight:[MessageListV getListCellHeightWithModel:model] + SECTION_HEIGHT * 2 - (self.cornerV.bottom + self.cornerV.width / 2)];
    [self.cornerV setBackgroundColor:model.STATUS ? self.bottomLineV.backgroundColor : [Theme orangeColor] ];
    
    [self.messageV reloadCarListDataWithModel:model] ;
}
+ (CGFloat)getCellHeightWithModel:(MessageModel *)model
{
    return [MessageListV getCarListCellHeightWithModel:model] + SECTION_HEIGHT;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
